<style>
#status{
	color: red;
	display: inline;
}
</style>
<!--
<script type="text/javascript">
	$(document).ready(function(){
			ValidateInCountry();
		var validator = $("#tbForm").validate({

		//ignore: ".ignore",
		rules: {			
			name:{
				required:true
			},			
			email: {
				required: true,
				email: true
			},
			country:{
				required:true
			}
		},
		messages: {
		name:"< if($lang=='th')echo "กรุณากรอก ชื่อ - นามสกุล";else echo "please enter name";?>",
		email: {
				required: "< if($lang=='th')echo "กรุณากรอก อีเมล์";else echo "please enter email";?>",
				minlength: "< if($lang=='th')echo "กรุณากรอก อีเมล์ ให้ถูกต้อง";else echo "Please enter a valid email address";?>"
		},
		country:"< if($lang=='th')echo "กรุณาเลือกประเทศ";else echo "please select country";?>",
		},
		// the errorPlacement has to take the table layout into account
		errorPlacement: function(error, element) {
			if ( element.is(":radio") )
				error.appendTo( element.parent().next().next() );
			else if ( element.is(":checkbox") )
				error.appendTo ( element.next() );
			else

				error.appendTo( element.parent().next() );
		},

                submitHandler: function() {
				  form.submit;
		},

		// specifying a submitHandler prevents the default submit, good for the demo
		// set this class to error-labels to indicate valid fields
		success: function(label) {
			// set &nbsp; as text for IE
			//label.html("").addClass("checked");  
			                          
		}
	});
		function ValidateInCountry()
		{
			var settings = $('#tbForm').validate().settings;
			delete settings.rules.city;
			delete settings.messages.city;
			delete settings.rules.province_id;
			delete settings.messages.province_id;
			
			settings.rules.province_id = {required: true};
			settings.messages.province_id = "< if($lang=='th')echo "กรุณาเลือกจังหวัด";else echo "please select province";?>";
		}
	})
</script>
-->
<h3>Member Management [Add / Edit Form]</h3>
<div></div>
<form id="tbForm" enctype="multipart/form-data" method="post" action="admin_member/save<?=$url;?>">
	<table class="tblist2">
		<tr>
			<th align="left"><? if($lang=='th')echo LBL_REGISTER_MEMBER_NAME_TH;else echo LBL_REGISTER_MEMBER_NAME_EN;?></th>
			<td>
			  <input type="hidden" name="id" value="<?=@$rs['id'];?>" />
            	<input type="hidden" name="registerdate" value="<?=@$rs['registerdate'];?>" />
            	<input type="hidden" name="isadmin" value="<?=@$rs['isadmin'];?>">
				<span><input name="name" type="text" value="<?=@$rs['name'];?>" size="50" class="" /></span>
				<div id="status"></div>
				<span class="txtOrange">*</span>
			</td>
		</tr>
		<tr>
			<th align="left"><? if($lang=='th')echo LBL_REGISTER_MEMBER_ADDRESS_TH;else echo LBL_REGISTER_MEMBER_ADDRESS_EN;?></th>
			<td>
				<span><input type="text" name="address1" cols="50" rows="4" size="50" maxlength="35" value="<?=@$rs['address1'];?>"></span>
				<div id="status"></div><br><br>
				<span><input type="text" name="address2" cols="50" rows="4" size="50" maxlength="35"  value="<?=@$rs['address2'];?>"></span><div></div><br>
				<span><input type="text" name="address3" cols="50" rows="4" size="50" maxlength="35"  value="<?=@$rs['address3'];?>"></span><div></div><br>
				<span><input type="text" name="address4" cols="50" rows="4" size="50" maxlength="35"  value="<?=@$rs['address4'];?>"></span><div></div><br>
			</td>			
		</tr>
		<tr id="dvProvinceList">
			<th align="left"><? if($lang=='th')echo LBL_REGISTER_MEMBER_PROVINCE_TH;else echo LBL_REGISTER_MEMBER_PROVINCE_EN;?></th>
			<td>
				<select name="province_id" >
					<option>-- select province --</option>
					<? 
					foreach($province as $item):
						$selected = $item['id']==$rs['province_id']? 'selected="selected"' :"";
						echo '<option value="'.$item['id'].'" '.$selected.'>'.$item['name_'.$lang]."</option>";
					endforeach;
					?>
				</select>
			</td>
		</tr>
		<tr>
			<th align="left"><? if($lang=='th')echo LBL_REGISTER_MEMBER_ZIPCODE_TH;else echo LBL_REGISTER_MEMBER_ZIPCODE_EN;?></th>
			<td>
				<input name="postcode" type="text" value="<?=@$rs['postcode'];?>" size="50" />
			</td>
		</tr>    		     
		<tr>
			<th align="left"><? if($lang=='th')echo LBL_REGISTER_MEMBER_TEL_TH;else echo LBL_REGISTER_MEMBER_TEL_EN;?></th>
			<td>
				<input name="tel1" type="text" class="number_only" value="<?=@$rs['tel1'];?>" size="4" maxlength="3" /> -
				<input name="tel2" type="text" class="number_only" value="<?=@$rs['tel2'];?>" size="6" maxlength="4" /> -
				<input name="tel3" type="text" class="number_only" value="<?=@$rs['tel3'];?>" size="6" maxlength="4" />
				<? if($lang=='th')echo 'ต่อ'; else echo 'Ext.';?>
				<input name="tel4" type="text" class="number_only" value="<?=@$rs['tel4'];?>" size="5" maxlength="5" />
			</td>
		</tr>  
		<tr>
			<th align="left"><? if($lang=='th')echo LBL_REGISTER_MEMBER_TEL_TH;else echo LBL_REGISTER_MEMBER_TEL_EN;?></th>
			<td>
				<input name="tel5" type="text" class="number_only" value="<?=@$rs['tel5'];?>" size="4" maxlength="3" /> -
				<input name="tel6" type="text" class="number_only" value="<?=@$rs['tel6'];?>" size="6" maxlength="4" /> -
				<input name="tel7" type="text" class="number_only" value="<?=@$rs['tel7'];?>" size="6" maxlength="4" />
				<? if($lang=='th')echo 'ต่อ'; else echo 'Ext.';?>
				<input name="tel8" type="text" class="number_only" value="<?=@$rs['tel8'];?>" size="5" maxlength="5" />
			</td>
		</tr>  
		<tr>
			<th align="left"><? if($lang=='th')echo LBL_REGISTER_MEMBER_FAX_TH;else echo LBL_REGISTER_MEMBER_FAX_EN;?></th>
			<td>
				<input name="fax1" type="text" class="number_only" value="<?=@$rs['fax1'];?>" size="4" maxlength="3" /> -
				<input name="fax2" type="text" class="number_only" value="<?=@$rs['fax2'];?>" size="6" maxlength="4" /> -
				<input name="fax3" type="text" class="number_only" value="<?=@$rs['fax3'];?>" size="6" maxlength="4" />
				<? if($lang=='th')echo 'ต่อ'; else echo 'Ext.';?>
				<input name="fax4" type="text" class="number_only" value="<?=@$rs['fax4'];?>" size="5" maxlength="5" />
			</td>
		</tr>
<tr>
		  <th align="left"><? if($lang=='th')echo LBL_REGISTER_MEMBER_EMAIL_TH;else echo LBL_REGISTER_MEMBER_EMAIL_EN;?></th>
	    <td>
	    	<span><input name="email" type="text" id="email" value="<?=@$rs['email'];?>" size="50" /></span> 
	    	<div id="status"></div>
			<span class="txtOrange">*</span>
	    	</td>
	  </tr>
		<tr>
		  <th align="left"><? if($lang=='th')echo LBL_REGISTER_MEMBER_PASSWORD_TH;else echo LBL_REGISTER_MEMBER_PASSWORD_EN;?></th>
		  <td><input type="password" name="password" value="" /><input type="hidden" name="current_password" value="<?=@$rs['password'];?>" />&nbsp; <?if(@$rs['id']<1){?><span class="txtOrange">*</span><? } ?></td>
	  </tr>
		<tr>
		  <th align="left"><? if($lang=='th')echo LBL_REGISTER_MEMBER_CONFIRM_PASSWORD_TH;else echo LBL_REGISTER_MEMBER_CONFIRM_PASSWORD_EN;?></th>
		  <td><input type="password" name="confirm_password" value="">&nbsp; <?if(@$rs['id']<1){?><span class="txtOrange">*</span><? } ?></td>
	  </tr>                        
		<tr>			
			<td colspan="2" align="center">
				<input type="submit" value="Save" class=""> <input type="button" value="  Back  " onclick="history.back();"> 
			</td>
		</tr>
	</table>
</form>
<? if(@$rs['id']>0){ ?>
<h3>Member Order List</h3>
<h3>Order History</h3>
<form name="search" >
<div>
	Search (Order No/Member Name) 
	<input type="text" name="search" value="<?=@$_GET['search'];?>" size="60">
	<input type="submit" name="submit" value="Search">	
</div>
</form>
<div id="pagination" class="pagination">
	<?=@$pagination;?>
</div>
	<table class="tblist2">
		<tr>
			<th align="left">OrderNo</th>
			<th>Billing Info</th>
			<th>Shipping Info</th>
			<th>Amount</th>
			<th>Status</th>
			<th>Order Date</th>
			<th>Delete</th>
		</tr>
<?php 

		  $rowStyle = '';
		  $page = (isset($_GET['page']))? $_GET['page']:1;
		  $i=(isset($_GET['page']))? (($_GET['page'] -1)* 10)+1:1;
		  foreach($result as $row):
		?>  
		<tr  <? if($rowStyle =='')$rowStyle = 'class="odd"';else $rowStyle = "";echo $rowStyle;?> >
		  <td align="left" onclick="window.location='<?=$urlpage;?>/form/<?=$row['id'];?>'">
		  	<?
		  	echo $row['order_no']; 
		  	?>
		  </td>
		  <td align="left" onclick="window.location='<?=$urlpage;?>/form/<?=$row['id'];?>'">
		  		<? $billing_address = GetOrderAddress($row['id'],'billing',$lang);
				echo $billing_address;?>
		  </td>
		  <td align="left" onclick="window.location='<?=$urlpage;?>/form/<?=$row['id'];?>'">
		  		<? $shipping_address = GetOrderAddress($row['id'],'shipping',$lang);
				echo $shipping_address;?>
		  </td>
		  <td align="left" onclick="window.location='<?=$urlpage;?>/form/<?=$row['id'];?>'">
		  	<?=number_format(GetOrderAmount($row['id']),2);?>
		  	</td>
		  <td align="left" onclick="window.location='<?=$urlpage;?>/form/<?=$row['id'];?>'">
		  	<?
		  		//Padding, Confirm, Shipping, Complete and Cancelled
		  		echo GetOrderStatus($row['status'],'admin');
		  	?>
		  </td>
		  <td>
		  	<?=$row['order_date'];?>
		  </td>
		  <td>
		  	<a href="<?=$urlpage;?>/delete/<?php echo $row['id']?>" style="text-decoration:none;" onclick="return confirm('<?php echo NOTICE_CONFIRM_DELETE?>')"><input type="button" class="btn_delete" /></a>  	
		  </td>
		  </tr>		
		<? 
				$i++;
		  		endforeach;

?>		
	</table>
<? } ?>